﻿<template>
    <div class="page">
        <div class="navbar">
            <div class="navbar-bg"></div>
            <div class="navbar-inner navbar-inner-centered-title">
                <div class="title text-color-primary">确认用户</div>
                <div class="right">
                    <!-- 关闭弹窗 -->
                    <a class="link popup-close color-primary" data-popup=".verify-user-popup">
                        <i class="icon f7-icons if-not-md">xmark_circle</i>
                        <i class="icon material-icons md-only ">xmark_circle</i>
                    </a>
                </div>
            </div>
        </div>
        <div class="page-content">
            <form class="list list-strong-ios list-outline-ios form-store-data" id="verify-user-from">
                <ul>
                    <li class="item-content item-input item-input-outline">
                        <div class="item-inner">
                            <div class="item-title item-floating-label">用户名</div>
                            <div class="item-input-wrap">
                                <input name="userName" type="text" placeholder="输入用户名" />
                                <span class="input-clear-button"></span>
                            </div>
                        </div>
                    </li>
                    <li class="item-content item-input item-input-outline">
                        <div class="item-inner">
                            <div class="item-title item-floating-label">密码</div>
                            <div class="item-input-wrap">
                                <input name="password" type="password" placeholder="输入密码" />
                                <span class="input-clear-button"></span>
                            </div>
                        </div>
                    </li>
                    <li class="item-content">
                        <div class="button-panel">
                            <button type="submit" class="button button-fill confirm-button">确定</button>
                        </div>
                    </li>
                </ul>
            </form>
            <br />
        </div>
    </div>
</template>
<script>
    export default (props, { $, $on, $f7, $h, $f7router, $theme, $update, $store }) => {
        /*
            $   Dom7 标准库
            $on 页面事件处理器绑定
            $f7 app实例对象
            $h  html模板字面量
        */
        let examId,reportId;

        $on('pageInit', (e, page) => {
            reportId = $store.state.reportId;
            examId = $store.state.examId;
            loadType();
            addSumitListener();
        })
        // 表单提交
        const addSumitListener = () => {
            $("#verify-user-from").on('submit', (e) => {
                e.preventDefault();
                let data = $f7.form.convertToData("#verify-user-from");
                fetch(`/api/report/verify-user?actionId=NextApi`, {
                    method: 'POST',
                    body: JSON.stringify(data),
                    headers: { 'Content-Type': 'application/json' }
                }).then((res) => {
                    res.json().then((result) => {
                        if (result.success) {
                            $f7.popup.close(".amend-popup");
                            $f7.emit('amendAllowed', result.data);
                        }
                    });
                })
            })
        }

        return $render;
    };
</script>
